<?php
	class HitHelper extends AppHelper
	{
		var $helpers = array('Html');
		function beforeRender()
		{
			if(is_object(ClassRegistry::getObject('view')))
			{ 
				$url = $this->Html->url(array('controller'=>"hits",'action'=>"addHit",'plugin'=>"stats",'admin'=>false));
				$js =<<<END
				<script type="text/javascript">
				function addhitimg()
				{
					var image = document.createElement("img");
					image.setAttribute("src","$url");
           image.setAttribute("height","0");
          image.setAttribute("width","0");
					document.getElementsByTagName('body').item(0).appendChild(image);
				}
				\$(document).ready(function(){
					addhitimg();
				})
				</script>
END;
			ClassRegistry::getObject('view')->addScript($js);
			}
		}
	}
?>